// This file tests the functions defined in LiveFolders.js, which will typically be helpers and global functions
// that are useful across all pages.  As such, it is OK to define multiple test classes in here.

registerNamespace("Gimme.UnitTests");
Gimme.UnitTests.CssTests = function()
{
	// .setUp is executed before each test
	var elem;
	this.setUp = function()
	{
		elem = document.createElement('div'); 
	};
	
	// add/remove class tests on a gimme object
	this.test_addClassToEmpty = function()
	{
		elem.className = '';
		this.addClassAndVerify(g(elem), 'foo', 'foo');
	};
	
	this.test_addClassToSingle = function()
	{
		elem.className = 'foo';
		this.addClassAndVerify(g(elem), 'bar', 'foo bar');
	};
	
	this.test_addClassWithSimilarName = function()
	{
		elem.className = 'foo';
		this.addClassAndVerify(g(elem), 'foo-bar', 'foo foo-bar');
	};
	
	this.test_addDuplicateClass = function()
	{
		elem.className = 'foo bar';
		this.addClassAndVerify(g(elem), 'foo', 'foo bar');
	};
	
	this.test_addMultipleClassesToEmpty = function()
	{
		elem.className = '';
		this.addClassAndVerify(g(elem), 'foo bar blah', 'foo bar blah');
	};
	
	this.test_addMultipleClassesToSingle = function()
	{
		elem.className = 'foo';
		this.addClassAndVerify(g(elem), 'bar blah', 'foo bar blah');
	};
	
	this.test_addMultipleDuplicateClassesWithOrderSwitch = function()
	{
		elem.className = 'foo bar blah';
		this.addClassAndVerify(g(elem), 'bar blah foo', 'foo bar blah');
	};
	
	this.test_addMultipleDuplicateClassesAndMultipleUniqueClasses = function()
	{
		elem.className = 'foo bar blah';
		this.addClassAndVerify(g(elem), 'dog bar cat', 'foo bar blah dog cat');
	};
	
	this.test_removeClassFromStart = function()
	{
		elem.className = 'foo bar blah';
		this.removeClassAndVerify(g(elem), 'foo', 'bar blah');
	};
	
	this.test_removeClassFromEnd = function()
	{
		elem.className = 'foo bar blah';
		this.removeClassAndVerify(g(elem), 'blah', 'foo bar');
	};
	
	this.test_removeClassFromMiddle = function()
	{
		elem.className = 'foo bar blah';
		this.removeClassAndVerify(g(elem), 'bar', 'foo blah');
	};
	
	this.test_removeMultipleClasses = function()
	{
		elem.className = 'foo bar blah';
		this.removeClassAndVerify(g(elem), 'foo blah', 'bar');
	};
	
	
	// helper functions
    this.addClassAndVerify = function(gObj, stringToAdd, expectedResult)
    {
        gObj.addClass(stringToAdd);
        AtlasUnit.Assert.areEqual(expectedResult, gObj.element().className, 'Class name does not match expected after call to .addClass(..)');
    };
	this.removeClassAndVerify = function(gObj, stringToRemove, expectedResult)
	{
		gObj.removeClass(stringToRemove);
		AtlasUnit.Assert.areEqual(expectedResult, gObj.element().className, 'Class name does not match expected after call to .removeClass(..)');
	};
}
Gimme.UnitTests.CssTests.registerClass("Gimme.UnitTests.CssTests");
Gimme.UnitTests.CssTests["AtlasUnit.IsTestFixture"] = true;
